using System;
using System.Collections.Generic;
using System.Text;
using Fuzzware.Common.Encoding;
using Fuzzware.Common.DataSchema;

namespace Fuzzware.ConvertFromXML.Processors
{
    class ByteLengthFn
    {
        public void ByteLength(ref byte[] operand, IOutputNode SourceNode, IOutputNode TargetNode)
        {
            int len = operand.Length;
            String EncValue = len.ToString();

            if (Coder.NeedsEncoding(TargetNode.TypeCode))
                EncValue = Coder.MakeEncoded(BitConverter.GetBytes(len), TargetNode.TypeCode);

            //operand = Coder.EncodeForOutput(TargetNode.OutputEncoding.GetBytes(EncValue), TargetNode.TypeCode, TargetNode.OutputAs, TargetNode.OutputEncoding);
            operand = TargetNode.OutputEncoding.GetBytes(EncValue);
        }
    }
}
